package com.blue.gateway.dto;

import com.blue.gateway.enums.ResultCodeEnum;

/**
 * @author xiaoyiming
 * @date 2020/5/5 14:39
 * @depiction
 */
public class ResultWrapper {
    private ResultWrapper() {
    }


    public static <T> Result fail() {
        return new Result<>(ResultCodeEnum.FAIL.getCode(), ResultCodeEnum.FAIL.getMessage());
    }

    public static <T> Result<T> fail(T data) {
        return new Result<>(ResultCodeEnum.FAIL.getCode(), ResultCodeEnum.FAIL.getMessage(), data);
    }

    public static <T> Result failEnum(ResultCodeEnum codeEnum) {
        return new Result<>(codeEnum.getCode(), codeEnum.getMessage());
    }

    public static <T> Result fail(ResultCodeEnum codeEnum, String errorMsg) {
        return new Result<>(codeEnum.getCode(), codeEnum.getMessage(), errorMsg);
    }

    public static <T> Result fail(String errorMsg) {
        return new Result<>(ResultCodeEnum.FAIL.getCode(), ResultCodeEnum.FAIL.getMessage(), errorMsg);
    }

    public static <T> Result success() {
        return new Result<>(ResultCodeEnum.SUCCESS.getCode(), ResultCodeEnum.SUCCESS.getMessage());
    }

    public static <T> Result<T> success(T data) {
        return new Result<>(ResultCodeEnum.SUCCESS.getCode(), ResultCodeEnum.SUCCESS.getMessage(), data);
    }
}
